//	--------------------------------------------------------------------
//	Copyright(C) 2006,2007 Zhao Yukun. All rights reserved.
//	This file is a part of the Xeres system.
//	Xeres 2007
//	Contact : xeres.engine@gmail.com
//	$(reservedInfo)
//	$(reservedDeclaration)
//	--------------------------------------------------------------------
///	@file	<CValueData.h>
///	@path	~/src/database/xdata/
///	@date	2007/11/28
///	@desc	Encapsulates simple value entry.

#pragma once

#include "xeres.h"

#include "object/varying_data.h"

#include "database/IData.h"

namespace xeres {

	/*!
		\class	CValueData
		\brief	Simple value entry (without objects & nodes).
	*/
	class CValueData : public IData
	{
	public:

		/// \name Constructor & Destructor
		//@{

		/// \ctor
		CValueData( const WString& name , VaryingDataType type );
		
		/// \dtor
		virtual ~CValueData( void );

		//@}

		DECL_IOBJECT_CLASS( CValueData , IData );

	public:

		/// \impl
		virtual bool GetInfo( DataInfo& datainfo );

		/// \impl
		virtual const WString& GetVarTypeName( void ) const;

		/// \impl
		virtual const ClassID GetVarTypeID( void ) const;

		/// \impl
		virtual bool SetBool( bool val );
		/// \impl
		virtual bool SetInt( int val );
		/// \impl
		virtual bool SetFloat( float val );
		/// \impl
		virtual bool SetPair( const Pair<float>& val );
		/// \impl
		virtual bool SetVector( const Vector<float>& val );
		/// \impl
		virtual bool SetQuat( const Quat<float>& val );
		/// \impl
		virtual bool SetColor( const Color4& val );
		/// \impl
		virtual bool SetMatrix( const Matrix<float>& val );
		/// \impl
		virtual bool SetString( const WString& val );

		/// \impl
		virtual bool GetBool( bool& val ) const;
		/// \impl
		virtual bool GetInt( int& val ) const;
		/// \impl
		virtual bool GetFloat( float& val ) const;
		/// \impl
		virtual bool GetPair( Pair<float>& val ) const;
		/// \impl
		virtual bool GetVector( Vector<float>& val ) const;
		/// \impl
		virtual bool GetQuat( Quat<float>& val ) const;
		/// \impl
		virtual bool GetColor( Color4& val ) const;
		/// \impl
		virtual bool GetMatrix( Matrix<float>& val ) const;
		/// \impl
		virtual bool GetString( WString& val ) const;

		/// \impl
		virtual const Key& GetKey( void ) const;

		/// \impl
		virtual bool Save( void );

		/// \impl
		virtual bool Reload( void );

		/*!
			\brief		Get data type.
		*/
		VaryingDataType GetValueDataType( void ) const { return m_data.GetVaryingDataType(); }

	private:

		Key					m_key;
		VaryingData			m_data;
	};

} // namespace xeres
